<template>
  <div>
    <el-form class="mb20" :inline="true">
      <el-form-item label="附件类型">
        <el-select
          @change="selectChange"
          v-model="fileSearch"
          style="width: 229px"
          placeholder="请选择"
          clearable
        >
          <el-option :value="null">全部</el-option>
          <el-option
            v-for="item in accessoryTypeArr"
            :key="item.value"
            :value="item.value"
            :label="item.title"
          />
        </el-select>
      </el-form-item>
      <el-form-item class="fr">
        <el-button icon="el-icon-plus" type="primary" @click="handleAdd">新增</el-button>
      </el-form-item>
    </el-form>
    <file-list ref="fileList" />
    <file-modal @refresh="handleRefresh" ref="fileModal" />
  </div>
</template>

<script>
import FileList from './FileList'
import FileModal from './FileModal'
import { getDicData } from '@/utils/util'

export default {
  components: {
    FileModal,
    FileList
  },
  data() {
    return {
      fileSearch: null,
      accessoryTypeArr: []
    }
  },
  mounted() {
    this.accessoryTypeArr = getDicData('002', '002005')
  },
  methods: {
    handleRefresh() {
      this.$refs.fileList.getAccessoryDetail()
    },
    handleAdd() {
      this.$refs.fileModal.edit(false, {})
      console.log('add', this.fileSearch)
    },
    selectChange(value) {
      this.$refs.fileList.change(value)
    }
  }
}
</script>
